;; core/number.scm - (c) rohan drape, 2004-2005

;; Three state numerical comparator.  Returns -1 is a is less than b,
;; 0 if a is equal to b, and 1 is a is greater than b.

(define (number-tsc a b) (if (= a b) 0 (if (< a b) -1 1)))

;; Quantize `n' to the nearest multiple of `quanta'.

(define (quantize n quanta) (* (roundE (/ n quanta)) quanta))
(define (make-quantizer quanta) (lambda (n) (quantize n quanta)))

;; If `n' is with in the range [a,b) return `n' else clip it.

(define (number-clip n a b) (if (< n a) a (if (>= n b) b n)))
(define (number-clip-zero n high) (number-clip n 0 high))
(define (number-clip-zero-one n) (number-clip-zero n 1))
